﻿Public Class RproformaDetalle

    Public Shared Function Añadir(ByVal descEmpresa As String, ByVal pProformaDetalle As EproformaDetalle) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DproformaDetalle.Añadir(descEmpresa, pProformaDetalle)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function AñadirVersus(ByVal descEmpresa As String, ByVal pProformaDetalle As EproformaDetalle) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DproformaDetalle.AñadirVersus(descEmpresa, pProformaDetalle)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function

    Public Shared Function Filtrar(ByVal descEmpresa As String, ByVal pProforma As EproformaCabecera) As List(Of EproformaDetalle)
        Dim proformaDetalles As List(Of EproformaDetalle) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                proformaDetalles = DproformaDetalle.Filtrar(descEmpresa, pProforma)
                If proformaDetalles Is Nothing Then proformaDetalles = New List(Of EproformaDetalle)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return proformaDetalles
    End Function
  
    Public Shared Function Filtrar(ByVal descEmpresa As String, ByVal pSeparacionVenta As EseparacionVenta) As List(Of EseparacionVentaDetalle)
        Dim separacionVentaDetalles As List(Of EseparacionVentaDetalle) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                separacionVentaDetalles = DproformaDetalle.Filtrar(descEmpresa, pSeparacionVenta)
                If separacionVentaDetalles Is Nothing Then separacionVentaDetalles = New List(Of EseparacionVentaDetalle)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return separacionVentaDetalles
    End Function
    Public Shared Function FiltrarEstado(ByVal descEmpresa As String, ByVal pSeparacionVenta As EseparacionVenta) As List(Of EseparacionVentaDetalle)
        Dim separacionVentaDetalles As List(Of EseparacionVentaDetalle) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                separacionVentaDetalles = DproformaDetalle.FiltrarEstado(descEmpresa, pSeparacionVenta)
                If separacionVentaDetalles Is Nothing Then separacionVentaDetalles = New List(Of EseparacionVentaDetalle)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return separacionVentaDetalles
    End Function
    Public Shared Function FiltrarEstadoParametrizacion(ByVal descEmpresa As String, ByVal pSeparacionVenta As EseparacionVenta) As List(Of EseparacionVentaDetalle)
        Dim separacionVentaDetalles As List(Of EseparacionVentaDetalle) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                separacionVentaDetalles = DproformaDetalle.FiltrarEstadoParametrizacion(descEmpresa, pSeparacionVenta)
                If separacionVentaDetalles Is Nothing Then separacionVentaDetalles = New List(Of EseparacionVentaDetalle)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return separacionVentaDetalles
    End Function

    Public Shared Function consultaInmueble(ByVal descEmpresa As String, ByVal pUnidInmobiliaria As EunidInmobiliarias) As List(Of EproformaDetalle)
        Dim proformaDetalles As List(Of EproformaDetalle) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                proformaDetalles = DproformaDetalle.consultaInmueble(descEmpresa, pUnidInmobiliaria)
                If proformaDetalles Is Nothing Then proformaDetalles = New List(Of EproformaDetalle)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return proformaDetalles
    End Function

    '-------    REPORTE COMISION VENDEDRO    --------'    
    Public Shared Function selecionar_selXVendedorComision(ByVal descEmpresa As String, ByVal pProformaDetalle As EproformaDetalle, ByVal filtro As String) As List(Of EproformaDetalle)
        Dim vendedorComisiones As List(Of EproformaDetalle) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                vendedorComisiones = DproformaDetalle.selecionar_selXVendedorComision(descEmpresa, pProformaDetalle, filtro)
                If vendedorComisiones Is Nothing Then vendedorComisiones = New List(Of EproformaDetalle)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return vendedorComisiones
    End Function

    '-------    REPORTE MENU - CONSULTAR PROFORMA DETALLE    ------------'
    Public Shared Function ReporteProformaDetalle(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal pProforma As EproformaCabecera) As List(Of EproformaDetalle)
        Dim proformasDetalle As List(Of EproformaDetalle) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                proformasDetalle = DproformaDetalle.ReporteProformaDetalle(descEmpresa, pProforma)
                If proformasDetalle Is Nothing Then proformasDetalle = New List(Of EproformaDetalle)

                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return proformasDetalle
    End Function

    '-------    MENU REPORTE EVOLTA / VERSUS    ------------'
    Public Shared Function ReporteProformaDetalleXEmpresa(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal pProforma As EproformaCabecera) As List(Of EproformaDetalle)
        Dim proformasDetalle As List(Of EproformaDetalle) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                proformasDetalle = DproformaDetalle.ReporteProformaDetalleXEmpresa(descEmpresa, pProforma)
                If proformasDetalle Is Nothing Then proformasDetalle = New List(Of EproformaDetalle)

                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return proformasDetalle
    End Function
    Public Shared Function ReporteProformaDetalleXVersus(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal pProforma As EproformaCabecera) As List(Of EproformaDetalle)
        Dim proformasDetalle As List(Of EproformaDetalle) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                proformasDetalle = DproformaDetalle.ReporteProformaDetalleXVersus(descEmpresa, pProforma)
                If proformasDetalle Is Nothing Then proformasDetalle = New List(Of EproformaDetalle)

                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return proformasDetalle
    End Function

End Class
